package com.mask.im.business.common.util;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

public class PageUtil {

	private static ThreadLocal<Page<?>> pageThreadLocal = new ThreadLocal<>();

	public static void setPage(Integer currentPage,Integer size){
		pageThreadLocal.set(new Page<>(currentPage,size));
	}

	public static long getCurrentPage(){
		long size = pageThreadLocal.get().getSize();
		return (pageThreadLocal.get().getCurrent()-1)*size;
	}

	public static long getLimitPage(){
		return pageThreadLocal.get().getCurrent();
	}

	public static long getSize(){
		return pageThreadLocal.get().getSize();
	}

	public static void removeThreadLocal(){
		pageThreadLocal.remove();
	}
}
